import React, {Component} from 'react'
import ReactDOM from 'react-dom'

// 父组件
class Parent extends Component{
    state = {
        lastName: "王"
    }

    render () {
        return(
            <div className='parent'>
                父组件:
                
                {/* (1) 父->子,,用state的方式传 */}
                <Child name = {this.state.lastName} />
            </div>
        )
    }
}

// 子组件
const Child = props => {
    return (
        <div className='child'>
            <p>子组件,接收到父组件的数据:{props.name}</p>
        </div>
    )
}

ReactDOM.render(<Parent />, document.getElementById('root'))